package dominion.player;

import dominion.Dominion;
import dominion.kingdom.Moat;
import dominion.kingdom.Smithy;

public class SmithyMoatPlayer extends TresureOnlyPlayer {

	boolean smithy = false;
	int moat;

	public SmithyMoatPlayer(Dominion dominion) {
		this("SmithyMoat", dominion);
	}

	public SmithyMoatPlayer(String name, Dominion dominion) {
		super(name, dominion);
	}

	@Override
	public int buy(Dominion dominion, int value) {
		if (smithy == false && 3 < value && dominion.buy(this, new Smithy())) {
			smithy = true;
		} else if ((1 < value && (moat < 1 /* || (6 < turn() && moat < 2) */))
				&& dominion.buy(this, new Moat())) {
			moat++;
		} else {
			super.buy(dominion, value);
		}
		return 0;
	}

}
